<template>
  <div class="type-detail-container">
    <!-- 类型卡片列表 -->
    <div class="type-cards">
      <div 
        v-for="(type, index) in types" 
        :key="index" 
        class="type-card"
        @click="showTypeDetails(type)"
      >
        <!-- 使用柔和的颜色而非黑色作为标题背景 -->
        <div class="card-header">
          <h3>{{ type.title }}</h3>
        </div>
        <div class="card-content">
          <img :src="type.image" :alt="type.title" class="card-image" />
          <p class="card-description">{{ type.description }}</p>
        </div>
      </div>
    </div>
    
    <!-- 单独的提示区域，而不是放在卡片上 -->
    <div class="info-hint">
      <i class="info-icon"></i>
      <span>选择任意卡片查看详细信息</span>
    </div>
    
    <!-- 详情弹窗 -->
    <div v-if="selectedType" class="type-detail-modal">
      <div class="modal-content">
        <div class="modal-header">
          <h2>{{ selectedType.title }}</h2>
          <button class="close-btn" @click="closeDetails">×</button>
        </div>
        <div class="modal-body">
          <img :src="selectedType.image" :alt="selectedType.title" class="detail-image" />
          <div class="detail-info">
            <p>{{ selectedType.fullDescription }}</p>
            <!-- 其他详细信息 -->
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      types: [
        // 示例数据，请替换为实际数据
        {
          title: "类型一",
          description: "这是类型一的简短描述",
          fullDescription: "这是类型一的详细描述，包含更多信息...",
          image: "/images/type1.jpg"
        },
        {
          title: "类型二",
          description: "这是类型二的简短描述",
          fullDescription: "这是类型二的详细描述，包含更多信息...",
          image: "/images/type2.jpg"
        },
        // 添加更多类型...
      ],
      selectedType: null
    };
  },
  methods: {
    showTypeDetails(type) {
      this.selectedType = type;
    },
    closeDetails() {
      this.selectedType = null;
    }
  }
};
</script>

<style>
.type-detail-container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.type-card {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  background-color: #fff;
}

.type-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.card-header {
  padding: 15px;
  /* 使用渐变或柔和的颜色替代黑色 */
  background: linear-gradient(135deg, #4f7cac, #6a98d0);
  color: white;
}

.card-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.card-content {
  padding: 15px;
}

.card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 10px;
}

.card-description {
  color: #555;
  line-height: 1.5;
}

.info-hint {
  text-align: center;
  color: #666;
  padding: 10px;
  font-size: 14px;
  margin-top: 10px;
  /* 可以使用淡色背景 */
  background-color: #f5f8fc;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 5px;

  background-size: contain;
}

/* 弹窗样式 */
.type-detail-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background-color: white;
  border-radius: 8px;
  width: 80%;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* 同样使用渐变替代纯色 */
  background: linear-gradient(135deg, #4f7cac, #6a98d0);
  color: white;
  border-radius: 8px 8px 0 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.detail-image {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 15px;
}

.detail-info {
  line-height: 1.6;
  color: #333;
}

/* 响应式调整 */
@media (min-width: 768px) {
  .modal-body {
    flex-direction: row;
    gap: 20px;
  }
  
  .detail-image {
    width: 40%;
    margin-bottom: 0;
  }
  
  .detail-info {
    width: 60%;
  }
}
</style>